1
|
|
|
var assert = require('chai').assert, |
2
|
|
|
GedcomX = require('../../'); |
3
|
|
|
|
4
|
|
|
describe('AtomPerson', function(){ |
5
|
|
|
|
6
|
|
|
it('Create plain', function(){ |
7
|
|
|
assert.instanceOf(new GedcomX.AtomPerson(), GedcomX.AtomPerson, 'An instance of AtomPerson is not returned when calling the constructor with new.'); |
8
|
|
|
assert.instanceOf(GedcomX.AtomPerson(), GedcomX.AtomPerson, 'An instance of AtomPerson is not returned when calling the constructor without new.'); |
9
|
|
|
}); |
10
|
|
|
|
11
|
|
|
it('Create with JSON', function(){ |
12
|
|
|
var person = GedcomX.AtomPerson({ |
13
|
|
|
uri: 'uri', |
14
|
|
|
name: 'name', |
15
|
|
|
email: 'email' |
16
|
|
|
}); |
17
|
|
|
assert.equal(person.getUri(), 'uri'); |
18
|
|
|
assert.equal(person.getName(), 'name'); |
19
|
|
|
assert.equal(person.getEmail(), 'email'); |
20
|
|
|
}); |
21
|
|
|
|
22
|
|
|
it('Build', function(){ |
23
|
|
|
var person = GedcomX.AtomPerson() |
24
|
|
|
.setUri('uri') |
25
|
|
|
.setName('name') |
26
|
|
|
.setEmail('email'); |
27
|
|
|
assert.equal(person.getUri(), 'uri'); |
28
|
|
|
assert.equal(person.getName(), 'name'); |
29
|
|
|
assert.equal(person.getEmail(), 'email'); |
30
|
|
|
}); |
31
|
|
|
|
32
|
|
|
it('toJSON', function(){ |
33
|
|
|
var data = { |
34
|
|
|
uri: 'uri', |
35
|
|
|
name: 'name', |
36
|
|
|
email: 'email' |
37
|
|
|
}, person = GedcomX.AtomPerson(data); |
38
|
|
|
assert.deepEqual(person.toJSON(), data); |
39
|
|
|
}); |
40
|
|
|
|
41
|
|
|
it('constructor does not copy instances', function(){ |
42
|
|
|
var obj1 = GedcomX.AtomPerson(); |
43
|
|
|
var obj2 = GedcomX.AtomPerson(obj1); |
44
|
|
|
assert.strictEqual(obj1, obj2); |
45
|
|
|
}); |
46
|
|
|
|
47
|
|
|
}); |